using System;
using System.Collections.Generic;

public static class Messenger<T, U, V>
{
	public static void AddListener(string eventType, Callback<T, U, V> handler)
	{
		MessengerInternal.OnListenerAdding(eventType, handler);
		Messenger<T, U, V>.eventTable[eventType] = (Callback<T, U, V>)Delegate.Combine((Callback<T, U, V>)Messenger<T, U, V>.eventTable[eventType], handler);
	}

	public static void RemoveListener(string eventType, Callback<T, U, V> handler)
	{
		MessengerInternal.OnListenerRemoving(eventType, handler);
		Messenger<T, U, V>.eventTable[eventType] = (Callback<T, U, V>)Delegate.Remove((Callback<T, U, V>)Messenger<T, U, V>.eventTable[eventType], handler);
		MessengerInternal.OnListenerRemoved(eventType);
	}

	public static void Broadcast(string eventType, T arg1, U arg2, V arg3)
	{
		Messenger<T, U, V>.Broadcast(eventType, arg1, arg2, arg3, MessengerInternal.DEFAULT_MODE);
	}

	public static void Broadcast(string eventType, T arg1, U arg2, V arg3, MessengerMode mode)
	{
		MessengerInternal.OnBroadcasting(eventType, mode);
		Delegate @delegate;
		if (Messenger<T, U, V>.eventTable.TryGetValue(eventType, out @delegate))
		{
			Callback<T, U, V> callback = @delegate as Callback<T, U, V>;
			if (callback == null)
			{
				throw MessengerInternal.CreateBroadcastSignatureException(eventType);
			}
			callback(arg1, arg2, arg3);
		}
	}

	private static Dictionary<string, Delegate> eventTable = MessengerInternal.eventTable;
}
